package com.fifth.apartment.config;

import com.fifth.apartment.quartz.MyQuartz;
import lombok.extern.slf4j.Slf4j;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * TODO
 *
 * @author Dao
 * @since 2024/7/15
 */
@Configuration
@Slf4j
public class QuartzConfig {

    @Bean
    public JobDetail jobDetail(){

        return JobBuilder.newJob(MyQuartz.class).storeDurably().build();
    }

    @Bean
    public Trigger trigger(){
        ScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule("0/5 * * * * ? ");
        return TriggerBuilder.newTrigger().forJob(jobDetail()).withSchedule(scheduleBuilder).build();
    }

}
